package com.xyzq.dao.sm.hibernate;

import java.util.List;

import org.appfuse.dao.hibernate.GenericDaoHibernate;
import org.appfuse.model.User;
import org.springframework.stereotype.Repository;

import com.xyzq.dao.sm.OrderClientDAO;
import com.xyzq.model.sm.OrderClient;

@Repository("orderClientDao")
public class OrderClientDaoHibernate extends
		GenericDaoHibernate<OrderClient, Long> implements OrderClientDAO {

	public OrderClientDaoHibernate() {
		super(OrderClient.class);
		// TODO Auto-generated constructor stub
	}

	public List<OrderClient> findByUser(User user) {
		// TODO Auto-generated method stub
		List list= getHibernateTemplate().find(
				"from OrderClient where FK_USER_USER=?", user.getId());
		if (list.isEmpty()) {
			return null;
		}
		return list;

	}

	public List<OrderClient> findByOrderClient(OrderClient orderClient) {
		// TODO Auto-generated method stub
		List list= this.getHibernateTemplate().find(
				"from OrderClient where client=? or id_card=?",
				orderClient.getClient(), orderClient.getIdCard());
		if (list.isEmpty()) {
			return null;
		}
		return list;
	}

}
